home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-03-06 | 38.2 KB | 1,081 lines |
-
-
- Volume 2, Number 2 February 1987
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: *************** ::
- :: ********************* ::
- :: *************************** ::
- :: ****************************** ::
- :: **************** ************ ::
- :: *************** ************* ::
- :: *************** ************** ::
- :: *************** *************** ::
- :: **************** ***************** ::
- :: ***************** ************* ::
- :: ***************** ************** Microrim ONLINE ::
- :: ****************** *************** """"""""""""""" ::
- :: ****************** **************** Online Technical News ::
- :: ****************** ***************** ::
- :: ****************** ****************** ::
- :: ****************** ******************* ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- Technical tips, techniques, and announcements from Microrim, Inc.
-
- Microrim ONLINE is published electronically approximately every month
- by Microrim, Inc. and distributed exclusively on the Microrim Bulletin
- Board System (BBS). You can obtain your copy free of charge by
- downloading it from the TECH-ED area of the FILES section. (206) 881-
- 8119. Setup: 8 data bits, 1 stop bit, No parity, and 300 or 1200
- baud; operating 24 hours, seven days a week.
-
- COPYRIGHT
- """""""""
- Copyright (c) 1987 by Microrim, Inc. All rights reserved. Microrim,
- Inc. authorizes the free distribution of this document for educational
- purposes as long as no charge is made and this document is distributed
- exactly as is without modification. Toward this end, this document
- may be stored in, uploaded to, and downloaded from any Bulletin Board
- Service (BBS) or electronic information service as long as no charge
- is made.
-
- CONTRIBUTIONS
- """""""""""""
- You are encouraged to contribute to MICRORIM ONLINE. Please upload
- your article, application, or application story to the Microrim BBS or
- send an IBM compatible disk in standard ASCII format to:
-
- Kay D. Dayss, Microrim ONLINE Editor
- Microrim, Inc.
- 3925 159th Ave. N.E.
- P.O. Box 97022
- Redmond, WA 98073-9722
-
- By submitting an article or application to MICRORIM ONLINE, you agree
- that the material is not confidential and that Microrim, Inc., may
- use, duplicate, modify, publish, or sell it without obligation or
- liability to you or anyone else.
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 1
-
-
- TRADEMARKS
- """"""""""
- R:BASE and Microrim are registered trademarks of Microrim, Inc.
- XRW is a trademark of Microrim, Inc.
- IBM is a registered trademark of International Business Machines Corp.
- XT and AT are trademarks of International Business Machines Corp.
-
- DISCLAIMER
- """"""""""
- Microrim, Inc., makes no representation or warranties with respect to
- the contents hereof, and specifically disclaims any implied warranties
- of merchantability or fitness for any particular purpose. Further,
- Microrim, Inc., reserves the right to revise this publication and to
- make changes in the content hereof without obligation to notify any
- person of such revision or change and shall not be liable for errors
- contained herein or for incidental or consequential damages in
- connection with the furnishing, performance, or use of this material.
- All opinions and product reviews in MICRORIM ONLINE are those of the
- author and not necessarily those of Microrim, Inc.
-
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: TABLE OF CONTENTS ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- Revision to 3labels Program ........................................ 1
- Conditional Printing in Reports - Negative Balances in Parentheses . 5
- Controlling your Printer ........................................... 8
- Converting Integer Dates to R:BASE Dates ...........................13
- Right-justifying Dollars on Forms ..................................14
- Rounding Reals and Doubles .........................................15
- Elapsed Time .......................................................16
- Subtracting Dates to Get Years and Months ..........................17
- Changing Alt 255s to Alt 32s .......................................18
-
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 2
-
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: TECHNICAL NOTES ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- REVISION TO 3LABELS PROGRAM
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-1
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : LABELS SUBCATEGORY : 3LABEL program
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- QUESTION:
- """"""""
- How can I get the 3LABELS program provided with R:BASE System V to use
- SORTED BY and WHERE clauses correctly?
-
-
-
- SOLUTION:
- """"""""
- You need to revise the 120th and 123rd lines in the 3LABELS.ASC file
- and then make a new 3LABELS.PRO using CodeLock. Some of the
- surrounding code is included below to help you locate the two lines.
-
- $COMMAND
- 3LABELS
- SET MESSAGE OFF
- o
- o
- o
- WHILE level2 EQ 0 THEN
- o
- o
- o
- IF pick2 EQ 2 THEN
- IF sort EXISTS THEN
- 120th--> SET VAR sortby TO SORTED BY .sort
- ENDIF
- IF cond EXISTS THEN
- 123rd--> SET VAR wclause TO WHERE .cond
- ENDIF
- RUN Prntlab IN 3LABELS.PRO
- IF type EQ Screen THEN
- BEEP
- WRITE " "
- WRITE "Press any key to continue"
- PAUSE
- ENDIF
- BREAK
- ENDIF
- ENDWHILE
- o
- o
- o
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 3
-
-
- Change line 120 to:
-
- SET VAR sortby TO ("SORTED BY" & .sort)
-
- Change line 123 to:
-
- SET VAR wclause TO ("WHERE" & .cond)
-
- These changes remove the ambiguity. The parentheses tell R:BASE
- System V that the variables are being set to expressions, and the
- quotations make it clear that what is inside the quotations should be
- considered one literal string.
-
- After making the changes to 3LABELS.ASC, use option five of CodeLock
- to make a new 3LABELS.PRO program.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 4
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- CONDITIONAL PRINTING IN REPORTS - NEGATIVE BALANCES IN PARENTHESES
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-2
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : REPORTS SUBCATEGORY : CONDITIONAL PRINTING
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- I want to print conditionally in my reports. For example, when I am
- printing dollar totals on a report and the balance is negative I want
- to print it enclosed in parentheses, but when it is positive I do not
- want the parentheses. I also want to print a list of names and
- underline only the people who are under 21.
-
-
-
- SOLUTION:
- """"""""
- Here are two approaches to conditional processing in reports. First,
- you can use R:BASE System V SuperMath functions in the report
- expressions in R:BASE System V reports. An example of this first
- approach is given in the Conditional Parentheses section below. The
- second approach involves a flag column in the table itself and is
- described in the Conditional Underlining section.
-
- Conditional Parentheses
-
- In this first example, the following functions do the job:
-
- o The IFLT (if less than) function is used to check and see if the
- balance is less than zero. If it is, then multiply by -1 and
- enclose it in parentheses.
- o The CHAR (character) function changes an ASCII integer code to
- the character the code represents. This function is used to
- convert the ASCII codes of 40 and 41 to the left and right
- parentheses characters. It is necessary to use the codes for the
- parentheses characters rather than the characters themselves
- because the IFLT function does not permit a text argument.
- o The CTXT (convert to text) function converts the currency balance
- value to text so that it is possible to concatenate the left
- parenthesis onto the front of it.
- o The RJS (right justify string) function is needed to right
- justify the dollar amount that has been converted to TEXT so that
- the decimal points align.
-
- In this example report, use the eight variable expressions listed on the
- next page to print customer balances. The report breaks on CUSTNUM, and
- for each customer number, adds up all the dollar amounts stored in an
- AMOUNT column and puts the result into a CURRENCY variable named VBAL.
- There are three fields located on this report in the break footer:
- CUSTNUM the column holding the customer number, VBALPRNT the TEXT
- variable holding the balance value to be printed (along with the left
- parenthesis if the balance is negative), and VRIGHT which is blank if
- the balance is positive and is the right parenthesis if the balance is
- negative. These three variables are shown on the following page.
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 5
-
-
-
- CUSTNUM - column VBALPRNT - variable VRIGHT - with the
- | | | E on top of the S
- F1 S E S EE
-
- All eight of the variables are cleared at break time. The expression
- list looks like this:
-
- 1: CURRENCY: VBAL = (.VBAL + 'AMOUNT')
- 2: INTEGER : VLEFTNUM = (IFLT(.VBAL,0,40,32))
- 3: INTEGER : VRITENUM = (IFLT(.VBAL,0,41,32))
- 4: CURRENCY: VBALPOS = (IFLT(.VBAL,0,(-1*.VBAL),.VBAL))
- 5: TEXT : VLEFT = (CHAR(.VLEFTNUM))
- 6: TEXT : VRIGHT = (CHAR(.VRITENUM))
- 7: TEXT : VBALTEXT = (.VLEFT & (CTXT(.VBALPOS)))
- 8: TEXT : VBALPRNT = (RJS(.VBALTEXT,30))
-
- The first expression VBAL accumulates the balance. The second and
- third variables VLEFTNUM and VRITENUM are assigned 40 (the ASCII code
- for the left parenthesis) and 41 (the ASCII code for the right
- parenthesis) if the balance is negative. If the balance is positive
- then both VLEFTNUM and VRITENUM are assigned ASCII 32 (the code for a
- blank). The fourth expression VBALPOS strips the negative sign if the
- balance is less than zero. The fifth and sixth expressions VLEFT and
- VRIGHT convert the ASCII codes stored in VLEFTNUM and VRITENUM to the
- appropriate characters. The fifth expression VBALTEXT converts the
- balance to TEXT. The sixth VBALPRNT right justifies it.
-
- Prior to running the report, issue the following three commands to set
- up the environment:
-
- CLEAR vbal vleftnum vritenum vbalpos vleft vright vbaltext vbalprnt
- SET ZERO OFF
- SET NULL " "
-
- Conditional Underlining
-
- To conditionally underline certain items, you can insert printer
- control codes directly into your database into a special column set up
- to hold temporary values. FLAG is a good name to use for this column.
- Make it a TEXT column. Now you can use the CHANGE command and the
- CHAR function to insert the appropriate printer control codes into the
- FLAG column for that row of data.
-
- To set up the appropriate CHANGE commands, determine the decimal ASCII
- codes that need to be sent to your printer to set underlining on and
- off. For example, on an EPSON FX-85, ESC "-1" turns underline on and
- ESC "-0" turns underline off. These translate to the decimal codes 27
- 45 49 to turn underline on and 27 45 48 to turn it off. To print a
- list of names stored in a NAME column and underline those under 21
- years old (as determined by an AGE column), use the following commands:
-
- CHANGE flag TO (CHAR(27)+CHAR(45)+CHAR(49)) IN tblname WHERE age LT 21
- CHANGE flag TO (CHAR(27)+CHAR(45)+CHAR(48)) IN tblname WHERE age GE 21
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 6
-
-
- When you define the report, locate the FLAG column immediately before
- the column you want to selectively underline. For this example, there
- are two only fields located on the report:
-
- FLAG - column NAME - column
- | |
- S ES E
-
- Now, when you print the report, the FLAG column will control whether
- the NAME is underlined or not. This is because the FLAG column
- contains either the printer control codes that turn underline on or
- the codes that turn underline off.
-
- For further information on printer control codes, see Microrim
- Technical Note number 87-1-3, Controlling Your Printer.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 7
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- CONTROLLING YOUR PRINTER
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-3
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- R:BASE 5000 ALL
- CATEGORY : PRINTING SUBCATEGORY : PRINTER CONTROL CODES
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- I need to send printer control codes to my printer from reports,
- command files, and from the R> prompt.
-
-
-
- SOLUTION:
- """"""""
- You can use your printer's special control characters within R:BASE.
- Each printer is different. Your printer manual explains what codes
- are applicable for your printer. Your R:BASE manual explains how to
- send printer control codes to your printer in an R:BASE 5000 or R:BASE
- System V report.
-
- It is also possible to control your printer by using global variables
- at the R> prompt (in R:BASE System V), in your reports, or in command
- files. In this way you can:
-
- o Change the appearance of reports by changing fonts for different
- sections.
- o Use different printers with the same application when one printer
- uses one set of control codes and another uses a different set.
- o Enter printer control codes directly at an R> prompt. This is
- useful, for example, when you want to print a list with the
- SELECT command and you want to skip over the perforations in the
- printer's paper.
-
- R:BASE 5000 Method
-
- Using this method, you can pass printer control codes to your reports
- through global variables. Below is a way to do this using menus that
- allow the user to pick the print style wanted for each section of the
- report.
-
- Essentially, you are changing the REPORTS table, but it is being done
- in a way that is transparent to the user. The main command file is
- PRINTER.2. It calls another command file named CHANGE.2. The two
- command files are listed below.
-
- If you have R:BASE System V, you do not need to change the REPORTS
- table, but you might like to adopt the "menus" approach used here. In
- this example for R:BASE 5000, the user is presented with three menus
- in succession. From the first menu, the user picks the print style
- for the page heading. Next, the user sees a menu asking for the style
- for the break heading. Finally, there is another menu for the detail.
- These examples can be changed to suit your particular report.
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 8
-
- Here are the menus:
-
- *( PGHEAD.MNU )
- +----------------------CHOOSE MODE FOR PAGE HEADING---------------------+
- | Normal Print Compressed Print Italics Emphasized Print |
- | Double-strike Underlined Enlarged Print |
- +-----------------------------------------------------------------------+
-
- *( BRKHEAD.MNU )
- +--------------------CHOOSE MODE FOR BREAK HEADING----------------------+
- | Normal Print Compressed Print Italics Emphasized Print |
- | Double-strike Underlined Enlarged Print |
- +-----------------------------------------------------------------------+
-
- *( DETAIL.MNU )
- +-----------------CHOOSE MODE FOR DETAIL INFORMATION--------------------+
- | Normal Print Compressed Print Italics Emphasized Print |
- | Double-strike Underlined Enlarged Print |
- +-----------------------------------------------------------------------+
-
- Here are the program listings for the two command files PRINTER.2 and
- CHANGE.2:
-
- *( PRINTER.2 )
- OPEN control
- CLEAR ALL VAR
- SET MESSAGE OFF
- SET ERROR MESSAGE OFF
-
- *(INITIALIZE VARIABLES TO NAMES OF REP VARS AS THEY APPEAR IN RDATA)
- SET VAR vhpon TO " HEADING (TEXT) ="
- SET VAR vhpoff TO " HEADING2 (TEXT) ="
- SET VAR vh1on TO " BRKHEAD (TEXT) ="
- SET VAR vh1off TO " BRKHEAD2 (TEXT) ="
- SET VAR vdon TO " DATALINE (TEXT) ="
- SET VAR vdoff TO " DATALIN2 (TEXT) ="
- SET VAR vpart3 TO " (VALUE, TEXT)"
- SET VAR vloop TO Y
-
- WHILE vloop = Y THEN
- NEW
- CHOOSE vhppick FROM PGHEAD.MNU
- IF vhppick = ESC THEN
- WRITE "No Choice Made"
- GOTO BOTTOM
- ENDIF
- IF vhppick = HELP THEN
- WRITE "Display a Help Screen Here"
- *( DISPLAY the help.scr file. )
- QUIT TO PRINTER.2
- ENDIF
-
- CHOOSE vh1pick FROM brkhead.mnu
- CHOOSE vdpick FROM detail.mnu
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 9
-
- *( Now, the user's choices are used to lookup the correct control
- code and recreate a row in the REPORTS table's RDATA column to
- replace the one which previously contained the printer control code)
- RUN CHANGE.2 USING .vhppick .vhpon .vhpoff
- RUN CHANGE.2 USING .vh1pick .vh1on .vh1off
- RUN CHANGE.2 USING .vdpick .vdon .vdoff
-
- OUTPUT PRINTER
- PRINT calls
- OUTPUT SCREEN
- ENDWHILE
- LABEL BOTTOM
-
-
- *( CHANGE.2 )
- SET VAR vcodeon TO STRING IN prnctrl WHERE desc = .%1
- SET VAR vcodeoff TO CANCEL IN prnctrl WHERE desc = .%1
- SET VAR vnewrpt1 TO .%2 & .vcodeon
- SET VAR vnewrpt1 TO .vnewrpt1 & .vpart3
- SET VAR vnewrpt2 TO .%3 & .vcodeoff
- SET VAR vnewrpt2 TO .vnewrpt2 & .vpart3
- CHANGE RDATA TO .vnewrpt1 IN REPORTS WHERE RDATA CON .%2 AND RNAME = calls
- CHANGE RDATA TO .vnewrpt2 IN REPORTS WHERE RDATA CON .%3 AND RNAME = calls
-
- Based on the user's choice, the CHANGE.2 command file looks up the
- appropriate codes in a table named PRNCTRL. The table PRNCTRL has
- been loaded previously with the appropriate control codes for turning
- that style on and off. Example contents of the table are listed
- below:
-
- STRING DESC CANCEL
- --------- ---------------- ---------
- <27 87 1> ENLARGED PRINT <27 87 0>
- <15> COMPRESSED PRINT <18>
- <27 52> ITALICS <27 53>
- <27 69> EMPHASIZED PRINT <27 70>
- <27 71> DOUBLE-STRIKE <27 72>
- <27 45 1> UNDERLINED <27 45 0>
- <18> NORMAL PRINT <18>
-
- Next, the CHANGE.2 command file concatenates the appropriate
- information together to form a new row for the REPORTS table which
- will replace the old definition of that variable.
-
- For example, if the name of the report variable is HEADING, then the
- data in the RDATA column in REPORTS looks like this:
-
- HEADING (TEXT) = <15> (VALUE,TEXT)
-
- The CHANGE.2 command file concatenates the VHPON variable (containing
- HEADING (TEXT) = ) with the variable containing the appropriate
- printer control code (for example, <27 72>) forming a temporary
- variable. The temporary variable is then concatenated to the VPART3
- variable, which contains the last portion of the report variable
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 10
-
- definition, (VALUE, TEXT), forming VNEWRPT1 which now contains the
- following: HEADING (TEXT) = <27 72> (VALUE, TEXT)
-
- The command file then executes a CHANGE command to replace the data in
- the RDATA column with the value of this new variable.
-
- Look near the top of the PRINTER.2 listing and you will find that in
- the INITIALIZE VARIABLES section each of the variables VHPON through
- VPART3 are initialized with leading blanks. These leading blanks are
- important because that is how the report variables are stored, so be
- sure to include them.
-
- When creating the menus using RBEDIT, make sure there is a line before
- the one that starts with the word ROW. This is a requirement for menu
- files. It can be a blank line, or it can contain the name of the menu
- if you plan to compile it into a procedure file. You have the option
- of displaying a help screen if the user presses [F10] instead of
- making a menu pick.
-
- Use the following files to create the menus shown on pages one and
- two:
-
- *( PGHEAD.MNU )
- ROW CHOOSE MODE FOR PAGE HEADING
- Normal Print
- Compressed Print
- Italics
- Emphasized Print
- Double-strike
- Underlined
- Enlarged Print
-
-
- *( BRKHEAD.MNU )
- ROW CHOOSE MODE FOR BREAK HEADING
- Normal Print
- Compressed Print
- Italics
- Emphasized Print
- Double-strike
- Underlined
- Enlarged Print
-
-
- *( DETAIL.MNU )
- ROW CHOOSE MODE FOR DETAIL INFORMATION
- Normal Print
- Compressed Print
- Italics
- Emphasized Print
- Double-strike
- Underlined
- Enlarged Print
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 11
-
- R:BASE System V Method
-
- R:BASE System V allows more flexibility because of the CHAR function
- and because global variables can be used directly in your report.
- Therefore, there is no need to modify the REPORTS table. You can set
- variables directly to printer control codes and then control the
- printer from the R> prompt or use the variable in a report and control
- the appearance of the report.
-
- For example, if the printer control code for turning on skip-over-
- perforation is ESC 78 and the code for turning it off is ESC 79, you
- can use the following short command file to turn it on, print a list
- with the SELECT command and then turn it back off:
-
- SET LINES 0
- SET VAR vperfon TEXT
- SET VAR vperfoff TEXT
- SET VAR vperfon TO (CHAR(27)+CHAR(78))
- SET VAR vperfoff TO (CHAR(27)+CHAR(79))
- OUTPUT PRINTER
- SHOW VAR vperfon
- SELECT name FROM list
- SHOW VAR vperfoff
- OUTPUT SCREEN
-
- If you like, you can also set up a series of menus from which the user
- can pick which print styles to use. With R:BASE System V you can load
- these menu choices directly into global variables such as VRPTHEAD
- (for the report header print style), VBRKHEAD (for the break header
- font), and VDETAIL (to control how the detail will look) and then use
- these global variables directly from the R> prompt (with the SHOW VAR
- command), inside a command file, or in your report. Sample menus are
- shown in the R:BASE 5000 Method section above.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 12
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- CONVERTING INTEGER DATES TO R:BASE DATES
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-4
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : CONVERSION SUBCATEGORY : INTEGER TO DATE
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- When I import data from a file into R:BASE, I have trouble with the
- date columns. In the file, the dates are listed without delimiters as
- six digit numbers. For example, October 1, 1986, is listed as:
-
- 100186
-
- When these fields are loaded, R:BASE interprets them as INTEGER data
- types. How can I convert them to the R:BASE DATE data type?
-
-
-
- SOLUTION:
- """"""""
- Use the commands listed below to define two columns for this field in
- your R:BASE table. Define one column ICOLNAME as an INTEGER column
- and load the value from the file into this column. Define the second
- column DCOLNAME as a computed DATE column. When you enter the
- DCOLNAME expression, do not enter the plus sign (+) shown at the end
- of each of the first two lines. These are continuation characters and
- are automatically inserted by R:BASE System V as needed.
-
- DEFINE dbname
- COLUMN
- icolname INTEGER
- dcolname =(RDATE((INT('icolname'/10000)),((INT('icolname'/100))+
- -((INT('icolname'/10000))*100)),('icolname'-((INT('icolname'/100))+
- *100)))) DATE
-
- For example, if a file named DATEFILE.DAT contains the integers 10186,
- 101087, and 123085, and if you load them into a table named DATETBL
- with the LOAD command (LOAD datetbl FROM datefile.dat USING icolname),
- the table will hold these rows:
-
- icolname dcolname
- -------- --------
- 10186 01/01/86
- 101087 10/10/87
- 123085 12/30/85
-
- The computed column automatically determines the correct date and
- format based on the INTEGER value in the INTEGER column.
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 13
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- RIGHT-JUSTIFYING DOLLARS ON FORMS
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-5
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : FORMS SUBCATEGORY : DOLLAR FORMATS
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- When entering data in a CURRENCY field in an R:BASE System V form,
- R:BASE System V automatically left-justifies CURRENCY columns so that
- it is easy for the operator to enter the data. However, when I am
- only displaying dollars on a form, I want to right-justify them so
- that the decimal points align.
-
-
-
- SOLUTION:
- """"""""
- David McCann of Classic Micro Systems, North Hollywood, CA provides
- this solution.
-
- Although you cannot enter values on a form and then align them within
- the same input field, you can align values which have been computed,
- displayed in a separate location on the form, or looked-up from
- another table and then displayed. Here is an example.
-
- First, start with any existing form on which you would like to display
- right-justified CURRENCY fields.
-
- Second, define an expression for each value you wish to locate on your
- form using the R:BASE System V conversion function CTXT to convert a
- CURRENCY amount to TEXT. For example, to convert the column AMOUNT to
- TEXT, define this expression: vtxtamt = (CTXT('amount'))
-
- Third, define another expression using the string function RJS to
- right-justify that text within a given field. For example, to right-
- justify the TEXT value defined previously in an eight-character field,
- define this expression: vramount = (RJS(.vtxtamt,8))
-
- Fourth, locate the right-justified variable VRAMOUNT on your form.
- Make this field display only by modifying the field characteristics to
- tell R:BASE that no new data will be entered in the field and that the
- data displayed in the field is not editable.
-
- Now you can display a column of CURRENCY values which all align on the
- decimal point. If you have ZERO set on, NULL CURRENCY values display
- as $0.00. With ZERO set off, NULL CURRENCY values appear as blanks.
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 14
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- ROUNDING REALS AND DOUBLES
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-6
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : MATH SUBCATEGORY : ROUNDING
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- QUESTION:
- """"""""
- How can I round a REAL or DOUBLE number to two decimal places?
-
-
-
- SOLUTION:
- """"""""
- Use the ANINT function.
-
- First, multiply the REAL or DOUBLE number by a multiplier constant
- (100 for example) after adding the applicable rounding constant (.005
- for this example). Next, take the ANINT of the result. Finally,
- divide the new result by the same multiplier constant. If you use the
- multiplier constant 100, you end up with a real number rounded to two
- decimal places.
-
- For example, the following code will round the number 28.376 to two
- decimal places.
-
- SET VAR vround REAL
- SET VAR vround TO 28.376
- SET VAR vround TO ((ANINT((.vround+.005)*100))/100)
-
- In this example, .005 is the rounding constant and 100 is the
- multiplier constant. After running these three commands, VROUND
- equals 28.38.
-
- The number of decimal places you want determines the multiplier and
- rounding constants in the expression. For one decimal place, add .05,
- multiply by 10, and then divide by 10. For two decimal places, add
- .005, multiply by 100, and then divide by 100. For three decimal
- places, add .0005, multiply by 1000, and then divide by 1000, and so
- on.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 15
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- ELAPSED TIME
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-7
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : MATH SUBCATEGORY : TIME MATH AND MIDNIGHT
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- Subtracting times that start after midnight from times that start
- before midnight results in a negative number. R:BASE System V assumes
- that the start time is later that day instead of the day before. For
- example, if the start time is 23:00, the stop time is 01:00, and the
- expression ((STOP-START)/60) defines elapsed minutes, R:BASE System V
- tells me that the elapsed minutes are -1320 when the answer I am
- seeking is 120 minutes.
-
-
-
- SOLUTION:
- """"""""
- Steven P. Vellella of BV Custom Software, Corapolis, PA, provides the
- following solution.
-
- Use the IFLT function. For example, if you want to put the elapsed
- time in a computed column named ELAPSE, and the start and stop times
- are in the columns START and STOP, use the commands listed below to
- define the three columns. Do not enter the plus sign (+) shown at the
- end of the first line in the ELAPSE expression. It is a continuation
- character automatically inserted by R:BASE System V.
-
- DEFINE dbname
- COLUMN
- start TIME
- stop TIME
- elapse =IFLT((('stop'-'start')/60),0,(('stop'-'start')/60+1440),+
- (('stop'-'start')/60)) INTEGER
-
- The IFLT function, used in the computed column ELAPSE, reads in
- English like this: If STOP minus START divided by 60 is less than
- zero, add 1440 (the number of minutes in a day) to the result.
- Otherwise, simply compute the result (('STOP'-'START')/60) without
- adding the additional minutes.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 16
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- SUBTRACTING DATES TO GET YEARS AND MONTHS
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-8
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : MATH SUBCATEGORY : DATE MATH
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- I want to subtract two dates and show the result as the number of
- approximate years and months.
-
-
- SOLUTION:
- """"""""
- You can subtract two dates and show the result as years and months by
- using the two R:BASE System V SuperMath functions INT and MOD.
- Subtract the two dates and divide the result by 365 (the number of
- days in a year) and use the two functions on the result. The INT
- (integer) function extracts the portion of the result that lies to the
- left of the decimal point. The MOD (modulus or remainder of one
- argument divided by a second) function pulls off the portion to the
- right of the decimal point.
-
- For example, if you have two DATE columns in your table named STARTDAY
- and STOPDAY, add two computed columns YEARS and MONTHS to hold the
- number of years and remaining months. Define these two computed
- columns using the expressions listed below.
-
- years =(INT(('stopday'-'startday')/365.)) INTEGER
- months =(INT(MOD(('stopday' - 'startday'),365.)/30.)) INTEGER
-
- The YEARS expression reads in English as follows: subtract STARTDAY
- from STOPDAY and divide the result by 365. Then take the INTEGER
- result (the part to the left of the decimal point) and store it in the
- YEARS column.
-
- The MONTHS expression reads: subtract STARTDAY from STOPDAY and divide
- the result by 365. Take the modulus of that number (the part that
- lies to the right of the decimal point) as a whole integer number.
- Now, divide that number by 30 to come up with the number of whole
- months.
-
- This method gives you the approximate number of years and months. It
- assumes that all months have 30 days and all years have 365 days. If
- you need a more accurate answer, you can do it by creating more
- complex expressions. If you want to be exact, you may need to use
- several different expressions, assign the intermediate results to
- variables, and then use the CHANGE command to put the final answer
- into the column. You could, for example, determine which months are
- being included and add the correct number of days for each month. You
- could even check for leap years and if the entire month of february is
- included for that year, use 29 days rather than 28. However, every
- level of complexity will add execution time. You need to assess
- whether the benefit (small increase in accuracy) is worth the cost in
- terms of execution time.
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 17
-
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- CHANGING ALT 255s TO ALT 32s
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- DATE : 1/87 NUMBER : 87-1-9
- PRODUCT : R:BASE SYSTEM V VERSIONS : ALL
- CATEGORY : CONVERSION SUBCATEGORY : ALT 255 to 32
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-
- NEED:
- """"
- At various times I like to use an ALT 255 in my R:BASE System V
- application files, menus, or reports. The ALT 255 looks like a normal
- blank (which is an ALT 32) on the screen, but it causes some printers
- to go haywire because it is interpreted as a control character. I
- like to use the ALT 255 to blank out sections in my reports and to
- make more attractive menu titles. How can I use ALT 255s but have the
- printer interpret them as ALT 32s?
-
-
-
- SOLUTION:
- """"""""
- You can change the defaults to have an ALT 255 interpreted as an ALT
- 32 when sent to the printer by revising the PRINTER.ASC file and
- making a new DEFAULT.MSG file. See chapter 10 in your R:BASE System V
- User's Manual for a complete description of the default files.
-
- To change ALT 255s to ALT 32s before they reach your printer, revise
- the PRINTER.ASC file and make sure that it resides with the
- DEFAULT.MSG file in the same directory as your R:BASE System V program
- files.
-
- After making a backup of the original version of the PRINTER.ASC file,
- use an editor to insert the following line as a new entry in the
- table:
-
- 255 32 0 0
-
- Note that the 255 starts in column three and the 32 starts in column
- nine. The first zero is in column 13, and the second zero is in
- column 16. You can place this new line anywhere in the list.
-
- Finally, make sure that DEFGEN.EXE, DEFAULT.ASC, and the new
- PRINTER.ASC files are all on your default drive and from the DOS
- prompt, type:
-
- DEFGEN DEFAULT.ASC
-
- This will generate a new DEFAULT.MSG file with your changes recorded.
-
-
-
-
-
-
-
-
-
- MICRORIM ONLINE February 1987 ------------------------------- Page 18
-